Skip to content

fix(buzz-agent): honor OPENAI_BASE_URL as fallback for base URL - #3705

Open
Chukwuebuka-2003 wants to merge 2 commits into
block:mainfrom
Chukwuebuka-2003:fix/openai-base-url-fallback
Open

fix(buzz-agent): honor OPENAI_BASE_URL as fallback for base URL#3705
Chukwuebuka-2003 wants to merge 2 commits into
block:mainfrom
Chukwuebuka-2003:fix/openai-base-url-fallback

Conversation

@Chukwuebuka-2003

@Chukwuebuka-2003 Chukwuebuka-2003 commented Jul 30, 2026

Copy link
Copy Markdown

Summary

When BUZZ_AGENT_PROVIDER is set to an OpenAI-compatible provider but OPENAI_COMPAT_BASE_URL is not explicitly set, the agent should fall back to the value of OPENAI_BASE_URL before using the default https://api.openai.com/v1. This matches user expectations when migrating from other tools that use OPENAI_BASE_URL as the standard env var.

Fixes #3630

Changes

  • In config.rs, the from_env() OpenAI base URL resolution now checks OPENAI_BASE_URL as a fallback when OPENAI_COMPAT_BASE_URL is unset, before falling through to https://api.openai.com/v1.

Testing

Existing tests pass — this is a pure backward-compatible fallback addition.

The OpenAI provider's base URL resolution only checked
OPENAI_COMPAT_BASE_URL, ignoring the more commonly expected
OPENAI_BASE_URL env var. This meant users setting a custom
base URL via the desktop persona env vars (which uses
OPENAI_BASE_URL) would have it silently ignored, with the
agent always falling back to api.openai.com.

Now checks OPENAI_BASE_URL first, falls back to
OPENAI_COMPAT_BASE_URL for backward compatibility, then
defaults to https://api.openai.com/v1.

Fixes block#3630

Signed-off-by: Chukwuebuka-2003 <ebulamicheal@gmail.com>
(cherry picked from commit 953c430)
@Chukwuebuka-2003
Chukwuebuka-2003 requested a review from a team as a code owner July 30, 2026 07:22
@Bartok9

Bartok9 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Independent review (Bartok9) — 2026-07-30 vs current main

Thanks for pushing on #3630 — agreeing env fallback is needed.

Blocking nit: precedence is inverted vs the PR description

Description says: when OPENAI_COMPAT_BASE_URL is unset, fall back to OPENAI_BASE_URL.

Current patch:

env("OPENAI_BASE_URL")
    .or_else(|| env("OPENAI_COMPAT_BASE_URL")
    .unwrap_or_else(|| "https://api.openai.com/v1".into()),

That prefers OPENAI_BASE_URL over the Buzz-native OPENAI_COMPAT_BASE_URL, so a leftover generic OPENAI_BASE_URL in the shell can override an intentional OPENAI_COMPAT_BASE_URL (opposite of typical specific-over-generic ordering).

Suggested:

env("OPENAI_COMPAT_BASE_URL")
    .or_else(|| env("OPENAI_BASE_URL"))
    .unwrap_or_else(|| "https://api.openai.com/v1".into()),

Testing gap

No unit test pins the two-env matrix (compat set / base only / neither). Worth a small from_env test with tempered env.

Scope note

Issue title mentions Agent defaults (Desktop). Env fallback still helps if defaults export OPENAI_BASE_URL into the agent process; if Desktop only writes another key, a second seam may remain — happy to help chase that if this lands and dogfood still breaks.

I can open a tiny residual PR with corrected precedence + tests if you want — won’t stomp if you push a fix here first.

@Bartok9

Bartok9 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Follow-up residual with corrected precedence + unit tests: #3773 — happy to close it if you flip the or_else order here and add similar tests on this branch first.

Flip the or_else order so OPENAI_COMPAT_BASE_URL (Buzz-specific) takes
precedence over the generic OPENAI_BASE_URL, with the default as final
fallback. This matches the PR description and the standard convention
of specific-over-generic env var precedence.

Also adds three unit tests covering the full env matrix:
- Both vars set: compat wins
- Only OPENAI_BASE_URL set: used as fallback
- Neither set: default used

Signed-off-by: Chukwuebuka-2003 <ebulamicheal@gmail.com>
@Chukwuebuka-2003

Copy link
Copy Markdown
Author

Thanks for the thorough review @Bartok9 — good catch on the precedence.

I've flipped the or_else order so OPENAI_COMPAT_BASE_URL is checked first (Buzz-specific), then OPENAI_BASE_URL as fallback, then the default. Also added three unit tests covering the full env matrix:

OPENAI_COMPAT_BASE_URL OPENAI_BASE_URL Expected
set set compat wins
unset set generic fallback
unset unset default

Your #3773 should be superseded now — happy to close it.

@Bartok9

Bartok9 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Perfect — precedence is now specific-over-generic and the three-case env matrix (compat set / base only / neither) is covered. LGTM. I've closed #3773 as superseded. Thanks for the quick turnaround!

@Chukwuebuka-2003

Copy link
Copy Markdown
Author

You're welcome

@Bartok9

Bartok9 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🙏 Likewise — nice clean fix. Hope #3630 stays quiet after this lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buzz-agent ignores custom OPENAI_BASE_URL from Agent defaults, always calls api.openai.com

2 participants